﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Gpc;
using YJKRevitCode.RevitTopologySuite.GPCAdapter;

namespace ModelCheckUtility
{
	public class GpcPolygonContrllor
	{
		public static List<List<List<Curve>>> CurvesAggregate(List<List<Curve>> areaCureOrg, int modelIndex = 0)
		{
			List<List<List<Curve>>> list = new List<List<List<Curve>>>();
			if (areaCureOrg.Count < 1)
			{
				return list;
			}
			for (int i = 0; i < areaCureOrg.Count; i++)
			{
				IPolygon polygon = GpcPolygonController.ConstructPolygon(areaCureOrg[i], null);
				for (int j = 0; j < areaCureOrg.Count; j++)
				{
					if (i != j)
					{
						Polygon clipPolygon = GpcPolygonController.ConstructPolygon(areaCureOrg[j], null);
						polygon = polygon.ClipPolygon(clipPolygon, (ClipOp)modelIndex);
					}
				}
				List<List<List<Curve>>> list2 = GpcPolygonController.PolygonToArarCurve(polygon);
				if (list2 != null && 0 < list2.Count)
				{
					list.AddRange(list2);
				}
			}
			return list;
		}
	}
}
